package com.fbinggun.dt.gui;

import com.fbinggun.dt.DailyTask;
import com.fbinggun.dt.task.Task;
import com.fbinggun.fbinggunutil.RandomUtil;
import com.fbinggun.fbinggunutil.price.IPrice;
import org.bukkit.configuration.ConfigurationSection;

import java.util.List;

public class ChoiceProject {
    String id;
    int slot;
    List<String> taskRandom;
    IPrice iPrice;
    List<String> lore;
    String permission;

    public ChoiceProject(String id,ConfigurationSection config){
        this.id=id;
        slot=config.getInt("Slot");
        lore =config.getStringList("Lore");
        DailyTask.debug("加载选项 接取价格"+config.getString("RefreshPrice.Price"));
        iPrice =IPrice.loadPrice(config.getConfigurationSection("RefreshPrice"));
        taskRandom=config.getStringList("TaskRandom");
        permission=config.getString("Permission");
        DailyTask.debug("加载选项 成功"+id);
    }

    public String getPermission() {
        return permission;
    }

    public Task getRandomTask(){
        if(taskRandom!=null&&taskRandom.size()!=0) {
            int count = taskRandom.size();
            String taskID = taskRandom.get(RandomUtil.getIntRandom(count, 1) - 1);
            DailyTask.debug("初始化玩家任务随机结果:选项 "+getId()+" 任务"+taskID);
            Task task = DailyTask.getTask(taskID);
            DailyTask.debug("随机结果:" +task.getId());
            return task;
        }
        return null;
    }

    public String getId() {
        return id;
    }

    public int getSlot() {
        return slot;
    }

    public IPrice getiPrice() {
        return iPrice;
    }

    public List<String> getLore() {
        return lore;
    }
}
